package com.liuj.springbucks.controller;

import com.liuj.springbucks.domain.Coffee;
import com.liuj.springbucks.service.CoffeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: liuj
 * @Date: 2023/3/24 21:16
 * @Description:
 * @Version: v1.0
 */
@RestController
//@RequestMapping(value = "/coffee")
@Api(value = "coffee", description = " ")
public class CoffeeController {

    @Resource
    private CoffeeService coffeeService;

    /**
     * 请求地址
     * http://localhost:8080/coffee/findall/json
     * <p>
     * restfu风格分页查询咖啡信息的json格式数据
     *
     * @return
     */
    @ApiOperation(value = "application/json", notes = "application/json")
    @RequestMapping(value = "/coffee/findall/json", method = RequestMethod.GET
            , produces = "application/json; charset=utf-8")
    public @ResponseBody List<Coffee> getParamAppJson() {
        List<Coffee> coffeeList = new ArrayList<>();
        coffeeList = coffeeService.findAllWithParam(1, 10);
        return coffeeList;
    }

    /**
     * 请求地址
     * http://localhost:8080/coffee/findall/xml
     * <p>
     * restfu风格分页查询咖啡信息的xml格式数据
     *
     * @return
     */
    @ApiOperation(value = "application/xml", notes = "application/xml")
    @RequestMapping(value = "/coffee/findall/xml", method = RequestMethod.GET
            , produces = "application/xml; charset=utf-8")
    public @ResponseBody List<Coffee> getParamAppXml(){
        List<Coffee> coffeeList = new ArrayList<>();
        coffeeList = coffeeService.findAllWithParam(1, 10);
        return coffeeList;
    }

}
